﻿using Twi.COMMON.Core;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace Twi.Test.COMMON.Core
{
    
    
    /// <summary>
    ///这是 ComplexModelTest 的测试类，旨在
    ///包含所有 ComplexModelTest 单元测试
    ///</summary>
    [TestClass()]
    public class ComplexModelTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///获取或设置测试上下文，上下文提供
        ///有关当前测试运行及其功能的信息。
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region 附加测试特性
        // 
        //编写测试时，还可使用以下特性:
        //
        //使用 ClassInitialize 在运行类中的第一个测试前先运行代码
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //使用 ClassCleanup 在运行完类中的所有测试后再运行代码
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //使用 TestInitialize 在运行每个测试前先运行代码
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //使用 TestCleanup 在运行完每个测试后运行代码
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///GetOriginalSQL 的测试
        ///</summary>
        [TestMethod()]
        public void GetOriginalSQLTest()
        {
            List<ComplexModel> listCondition = null; // TODO: 初始化为适当的值
            string expected = string.Empty; // TODO: 初始化为适当的值
            string actual;
            actual = ComplexModel.GetOriginalSQL(listCondition);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }

        [TestMethod]
        public void SerializeEnum()
        {
            List<ComplexModel> list = new List<ComplexModel>();
            ComplexModel condition = new ComplexModel();
            condition.Field = "FName";
            condition.Value = "xzh";
            condition.COperator = CompareOperator.GreaterThan;
            condition.JOperator = JoinOperator.OR;
            list.Add(condition);

            ComplexModel condition2 = new ComplexModel();
            condition2.Field = "xl";
            list.Add(condition2);

            string str = JSSerialize.Serialize(list);

            //string str = JSSerialize.Serialize(condition);
            //ComplexModel model = JSSerialize.Deserialize<ComplexModel>(str);
            //Assert.AreEqual(condition.Field, model.Field);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
    }
}
